<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/2/15
  Time: 16:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>显示所有的人员信息</title>
    <link href="./static/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<table  class="table-bordered table-striped table-hover table-condensed">
    <caption>安居户籍管理系统</caption>
    <thead>
    <tr >
        <td colspan="8"><button class="btn btn-success"><a href="toAddPerson">添加人员</a></button></td>
    </tr>
    <tr>
        <td>人员编号</td>
        <td>人员姓名</td>
        <td>户口所在地</td>
        <td>人员年龄</td>
        <td>家庭住址</td>
        <td>创建时间</td>
        <td colspan="2">操作</td>
    </tr>
    </thead>
    <c:forEach items="${personList}" var="person">
        <tr>
            <td>${person.personid}</td>
            <td>${person.personname}</td>
            <td>${person.areaname}</td>
            <td>${person.personage}</td>
            <td>${person.personaddress}</td>
            <td> <f:formatDate value="${person.createTime}" pattern="YYYY年MM月dd日 HH时mm分ss秒"></f:formatDate></td>
                <%--                <a href="deletePerson?personId=${person.personid}">删除</a>--%>
            <td>
                <button onclick="messageDel(${person.personid})">删除</button>
            </td>
            <td>
                <button onclick="messageUpdate(${person.personid})">修改</button>
            </td>
        </tr>
    </c:forEach>
</table>
</body>
<script>
    function messageDel(personid) {
        //alert("测试删除:"+personid);
        //提示信息
        let b = confirm("你确定要删除此数据吗？");
        if (b) {
            //删除
            window.location.href = "deletePerson?personId=" + personid;
        }
    }

    function messageUpdate(personid) {
        //去后端接口请求数据，并跳转到修改页面
        window.location.href = "toUpdatePerson?personId=" + personid;
    }
</script>
</html>
